<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>充值会员</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/layui/css/layui.css">
</head>
<body>
    <table class="layui-hide" id="vipTable" lay-filter="vipTable"></table>

    <script type="text/html" id="vipEdit">
        <a class="layui-btn layui-btn-xs" lay-event="member">充值</a>
    </script>

    <script src="${pageContext.request.contextPath}/layui/layui.js"></script>
    <script>
        layui.use(['table','layer','form','jquery'], function () {
            var table = layui.table,
                layer = layui.layer,
                form = layui.form,
                $ = layui.jquery;

            table.render({
                elem: '#vipTable',
                url:'${pageContext.request.contextPath}/selectAllVip.do',
                title: 'vip管理',
                toolbar:"#vipAdd",
                cols: [[
                    {field:'vtName', title:'会员名称'},
                    {field:'vipDay', title:'会员天数'},
                    {field:'vipMoney', title:'会员价格'},
                    {fixed: 'right', title:'操作', toolbar: '#vipEdit'}
                ]]
            });

            //监听充值会员事件
            table.on('tool(vipTable)', function(obj){
                var data = obj.data;//obj.data代表一行数据
                var vtId = data.vtId;
                if(obj.event === 'member'){
                    layer.open({
                        type:1,//type=1 弹出页面层
                        title:"付款",
                        content: $("#twoCode").html(),//弹出层内容
                        area:['260px','320px'],
                        btn: ['保存','取消'],
                        yes: function(index,layero){//点击保存按钮执行的方法
                            $.post(("${pageContext.request.contextPath}/insertMember.do"),{vtId:vtId},function(result){
                                if(result.status){
                                    layer.msg(result.message);
                                    layer.close(index);//关闭弹框
                                }else{
                                    layer.msg(result.message);
                                    return false;
                                }
                            },"json");
                        },btn2: function(index, layero){//点击取消按钮执行的方法
                        },success: function(){//只要打开弹出层就执行此方法
                        }
                    });
                }
            });
        });
    </script>

    <script type="text/html" id="twoCode">
        <img style="margin-left:30px;" src="${pageContext.request.contextPath}/images/getMoney.png" width="200px" height="200px" >
    </script>

</body>
</html>
